package com.sx.gongzhong.pest;

import com.sx.gongzhong.model.CommentBean;
import com.sx.gongzhong.model.ConvenniceAppealBean;
import com.sx.gongzhong.model.HeadParamBean;
import com.sx.gongzhong.model.ReplyUserBean;
import com.sx.gongzhong.net.AppealManager;
import com.sx.gongzhong.net.BaseCallBack;
import com.sx.gongzhong.view.ConvenniceAppealDetailView;

import java.util.Map;

/**便民诉求详情
 * Created by admin on 2018/1/10.
 */

public class ConvenniceAppealDetailPest {
    private ConvenniceAppealDetailView convenniceAppealDetailView;

    public ConvenniceAppealDetailPest(ConvenniceAppealDetailView convenniceAppealDetailView) {
        this.convenniceAppealDetailView = convenniceAppealDetailView;
    }
    //便民诉求 详情
    public void getAppealDetail(String appealId) {
            Map<String,Object> map = HeadParamBean.getHead();
            map.put("appealId",appealId);
            new AppealManager().getAppealDetail(map, new BaseCallBack<ReplyUserBean.BaseResult<ConvenniceAppealBean>>() {
                @Override
                public void onSuccess(ReplyUserBean.BaseResult<ConvenniceAppealBean> response) {
                    convenniceAppealDetailView.getAppealDetailSuccess(response.data);
                }
                @Override
                public void onFailures(String message) {
                    convenniceAppealDetailView.showError("获取详情失败");
                }
            });
    }
    //便民诉求 点赞
    public void addPraise(String appealId) {
        Map<String,Object> map = HeadParamBean.getHead();
        map.put("appealId",appealId);
        new AppealManager().addPraise(map, new BaseCallBack<ReplyUserBean.BaseResult<Integer>>() {
            @Override
            public void onSuccess(ReplyUserBean.BaseResult<Integer> response) {
                convenniceAppealDetailView.addPraiseSuccess(response.data);
            }
            @Override
            public void onFailures(String message) {
                convenniceAppealDetailView.showError(message);
            }
        });
    }
    //便民诉求 添加评论
    public void addComment(String appealId,String content) {
        Map<String,Object> map = HeadParamBean.getHead();
        map.put("dataId",appealId);
        map.put("content",content);
        new AppealManager().addAppealComment(map, new BaseCallBack<ReplyUserBean.BaseResult<CommentBean>>() {
            @Override
            public void onSuccess(ReplyUserBean.BaseResult<CommentBean> response) {
                convenniceAppealDetailView.addCommentSuccess(response.data);
            }
            @Override
            public void onFailures(String message) {
                convenniceAppealDetailView.showError(message);
            }
        });
    }
    //便民诉求 删除
    public void deleteAppeal(String appealId) {
        Map<String,Object> map = HeadParamBean.getHead();
        map.put("ids",appealId);
        new AppealManager().deleteAppeal(map, new BaseCallBack<ReplyUserBean.BaseResult<Boolean>>() {
            @Override
            public void onSuccess(ReplyUserBean.BaseResult<Boolean> response) {
                convenniceAppealDetailView.deleteAppealSuccess(response.data);
            }
            @Override
            public void onFailures(String message) {
                convenniceAppealDetailView.showError(message);
            }
        });
    }
}
